﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using hessiancsharp.client;
namespace hessian_test
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private static string CODE = "accc9105df5383111407fd5b41255e23";

        private Validate v;

        private void Form1_Load(object sender, EventArgs e)
        {
            // string url = "http://127.0.0.1:8080/ps/remoting/cus/cv";
            // hessanTest = (ValidateInterface)factory.Create(typeof(ValidateInterface), url);
            try
            {
                v = new Validate("http://127.0.0.1:8080/ps/remoting/cus/cv", CODE, "");
                v.init();
                timer1.Interval = 1000;
                timer1.Start();
            }
            catch (Exception ex)
            {
                trace("无法启动程序");
            } 
        }

        private void trace(string msg)
        {
            this.listBox1.Items.Insert(0, "[" + DateTime.Now.ToString() + "]:" + msg);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!v.validateByCode())
            {
                timer1.Stop();
                trace("无法使用该程序");
            }else{
                trace("验证通过");
            }
        }
    }
}
